import pygame

pygame.init()


class BaseGame:
    def __init__(self,
                 minsize=25,
                 maxsize=50,
                 WIDTH=600,
                 HEADER=30,
                 HEIGHT=660,
                 TITLE="Maze",
                 FPS=30,
                 ):
        # 游戏的一些属性
        self.WIDTH = WIDTH
        self.HEADER = HEADER
        self.HEIGHT = HEIGHT
        self.WINDOW = (self.WIDTH, self.HEIGHT)
        self.TITLE = TITLE
        self.FPS = FPS
        self.FONT_SIZE = 16
        self.FONT = pygame.font.Font('./FZSTK.TTF', self.FONT_SIZE)
        self.BUTTONS = []
        self.SCREEN = pygame.display.set_mode(self.WINDOW)
        self.white = (255, 255, 255)
        self.black = (0, 0, 0)
        self.red = (255, 0, 0)
        self.green = (0, 255, 0)
        self.cyan = (0, 255, 255)
        # 迷宫大小
        self.min = minsize
        self.max = maxsize
        pygame.display.set_caption(self.TITLE)

    def draw_rect(self, x, y, len, color):
        pygame.draw.rect(self.SCREEN, color, [x, y, len, len], 0)

    def draw_button(self, x, y, color, len, height, text):
        pygame.draw.rect(self.SCREEN, color, [x, y, len, height], 1)
        text_surface = self.FONT.render(text, True, color)
        self.SCREEN.blit(text_surface, (x + 20, y + 2))

